﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryToCSV
{
    public partial class Interface : Form
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Interface());
        }
        public Interface()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
        {

        }

        private void button_SelectFolder_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                this.textBox_folderPathSource.Text = folderBrowserDialog1.SelectedPath;
            }
        }

        private void button_export_Click(object sender, EventArgs e)
        {
            var dirStringSource = this.textBox_folderPathSource.Text;
            var dirStringTarget = this.textBox_folderPathTarget.Text;
            if (dirStringSource.Length <= 0) return;
            if (!Directory.Exists(dirStringSource))
            {
                DialogResult result = MessageBox.Show("Folder: " + dirStringSource + " does not exist","", MessageBoxButtons.OK);
                return;
            }
            var ioHandler = new FileIO(dirStringSource, dirStringTarget);
            ioHandler.Read();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox_folderPathTarget.Text = folderBrowserDialog1.SelectedPath;
            }
        }
    }
}   
